"""
URL configuration for myblog project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
# pip install django --target=D:\myblog\.venv\Lib\site-packages  安装到项目虚拟环境中


from django.contrib import admin
from django.urls import path, include

from home import views

urlpatterns = [
    path('admin/', admin.site.urls),


    path('user/', include(('user.urls', 'users'), namespace='users')),
    path('home/', include(('home.urls', 'home'), namespace='home')),
    path('',views.IndexView.as_view(),name='index'),
]
# 将 Django 项目的媒体文件 URL 模式添加到 urlpatterns 中
# 这行代码使 Django 能够在开发环境中 serving 上传的媒体文件
# 参数说明:
# - settings.MEDIA_URL: 媒体文件的基 URL，通常是一个字符串，如 '/media/'
# - settings.MEDIA_ROOT: 服务器上存储媒体文件的实际目录路径
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)